package com.tsing.wms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tsing.wms.entity.StockEntity;
import com.tsing.wms.vo.req.SupplierPageReqVO;
import com.tsing.wms.vo.resp.StockRespVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 库存表 Mapper 接口
 * </p>
 *
 * @author TheTsing
 * @since 2022-04-13
 */
public interface StockMapper extends BaseMapper<StockEntity> {

    @Select("<script>" +
            "select s.*,g.name goodsName,st.name storehouseName\n" +
            "from t_stock s\n" +
            "left join t_goods g on s.goods_id=g.id\n" +
            "left join t_storehouse st on s.storehouse_id=st.id\n" +
            "<where>" +
            "<if test=\"reqVO.name!=null and reqVO.name!=''\">and g.name like concat('%',#{reqVO.name},'%')</if>" +
            "</where>" +
            "</script>")
    IPage<StockRespVO> stockPage(IPage<StockRespVO> page, @Param("reqVO") SupplierPageReqVO reqVO);

}
